using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Entities;
using Utility;
using BUS;
public partial class Admin_DoanhNghiepEdit : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            load_data();
        }
    }
    private void load_data()
    {
        try
        {
            int id = int.Parse(Request.QueryString["id"].ToString());
            tbDoanhNghiep doanhnghiep = tbDoanhNghiepBUS.GetById(id);
            if (doanhnghiep != null)
            {
                txt_MaDN.Text = doanhnghiep.IdDoanhNghiep.ToString();
                txt_TenDN.Text = doanhnghiep.TenDoanhNghiep.ToString();
                txt_diachi.Text = doanhnghiep.DiaChi.ToString();
                txt_dienthoai.Text = doanhnghiep.DienThoai.ToString();
            }
        }
        catch
        {
            Response.Redirect("~/Admin/DoanhNghiepList.aspx");
        }
    }
    protected void btn_Update_Click(object sender, EventArgs e)
    {
        try
        {
            tbDoanhNghiep doanhnghiep = tbDoanhNghiepBUS.GetById(int.Parse(txt_MaDN.Text));
            doanhnghiep.TenDoanhNghiep = txt_TenDN.Text;
            doanhnghiep.DiaChi = txt_diachi.Text;
            doanhnghiep.DienThoai = txt_dienthoai.Text;
            tbDoanhNghiepBUS.Update_DN (doanhnghiep);
            Response.Redirect("~/Admin/DoanhNghiepList.aspx");
        }
        catch
        {
            Response.Redirect("~/Admin/DoanhNghiepList.aspx");
        }
    }
}
